import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

/**
 * Created by berkbozkurt on 07/03/15.
 */
public class MediumBrick extends Rectangle implements Brick {

    private Point location;
    private Dimension size;
    private int life;

    public MediumBrick() {
        super();
        life = 2;
        location = new Point();
        width = 100;
        height = 30;
    }

    @Override
    public void setLocation(int x, int y) {
        location.x = x;
        location.y = y;

    }

    @Override
    public Point getLocation() {
        return location;
    }

    @Override
    public BufferedImage getImage() {
        BufferedImage img = null;
        try {
            img = ImageIO.read(new File("resources/mediumBrick.png"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return img;
    }

    @Override
    public Dimension getSize() {
        return size;
    }

    @Override
    public void setSize(Dimension size) {
        this.size = size;
    }

    @Override
    public void update() {
        setFrame(location.x, location.y, size.getWidth(), size.getHeight());
    }

    @Override
    public void decreaseLife() {
        life--;
    }

    @Override
    public int getLife() {
        return life;
    }

    @Override
    public void destroyBrick() {
        life = 0;
    }
}
